/* **********************************************************************************
 *
 * Copyright (c) Ascend.NET Project. All rights reserved.
 *
 * This source code is subject to terms and conditions of the Shared Source License
 * for Ascend. A copy of the license can be found in the License.html file
 * at the root of this distribution. If you can not locate the Shared Source License
 * for Ascend, please send an email to ascend_adm@hotmail.com.
 * By using this source code in any fashion, you are agreeing to be bound by
 * the terms of the Shared Source License for Ascend.NET.
 *
 * You must not remove this notice, or any other, from this software.
 *
 * **********************************************************************************/

using System;
using System.Collections.Generic;
using System.Drawing.Design;
using System.Text;
using System.ComponentModel;
using System.Security;
using System.Security.Permissions;
using System.Drawing;
using System.Drawing.Drawing2D;
using Ascend.Resources;
using System.Windows.Forms;

namespace Ascend.Windows.Forms
{
    /// <summary>
    /// User interface (UI) for representing and editing the values of objects of the supported data types in a tab.
    /// </summary>
    [TypeConverterAttribute(typeof(GradientTabPageTabConverter))]
    [PermissionSet(SecurityAction.LinkDemand, Name = "FullTrust")]
    [PermissionSet(SecurityAction.InheritanceDemand, Name = "FullTrust")]
    public class GradientTabPageTabProperty : UITypeEditor
    {
        private GradientTabPage _gradientTabPage;

        /// <summary>
        /// Gets or sets the parent GradientTabPage.
        /// </summary>
        [Browsable(false)]
        public GradientTabPage GradientTabPage
        {
            get
            {
                return this._gradientTabPage;

            }

            set
            {
                this._gradientTabPage = value;

            }

        }

        /// <summary>
        /// Gets or sets the gradient high (lighter) color for the tab when it is active.
        /// </summary>
        /// <value>
        /// <para>
        /// System.Drawing.Color . A Color that represents the gradient high color of the tab when it is active.
        /// </para>
        /// <para>
        /// This property is read/write. 
        /// </para>
        /// </value>
        [RefreshProperties(RefreshProperties.Repaint)]
        [ResourceCategoryAttribute("AppearanceCategory"), ResourceDescriptionAttribute("ActiveGradientHighColorDescription"), ResourceDisplayName("DisplayNameActiveGradientHighColor")]
        public Color ActiveGradientHighColor
        {
            get
            {

                return this._gradientTabPage.ActiveGradientHighColor;

            }

            set
            {
                this._gradientTabPage.ActiveGradientHighColor = value;

            }
        }

        /// <summary>
        /// Determines if the ActiveGradientHighColor property has default values or not.
        /// </summary>
        /// <remarks>
        /// This method is used internally to the control and should not be called by your code.
        /// </remarks>
        /// <returns>true or false</returns>
        public bool ShouldSerializeActiveGradientHighColor()
        {
            if (this._gradientTabPage.Parent != null)
            {
                GradientTab parentGradientTab = this._gradientTabPage.Parent as GradientTab;

                if (parentGradientTab != null)
                {
                    if (parentGradientTab.TabActiveGradientHighColor == this._gradientTabPage.ActiveGradientHighColor)
                    {
                        return false;

                    }
                    else
                    {
                        return true;

                    }

                }
                else
                {
                    return true;

                }

            }
            else
            {
                return true;

            }

        }

        /// <summary>
        /// Gets or sets the gradient low (darker) color for the button when it is active.
        /// </summary>
        /// <value>
        /// <para>
        /// System.Drawing.Color . A Color that represents the gradient low color of the button when it is active.
        /// </para>
        /// <para>
        /// This property is read/write. 
        /// </para>
        /// </value>
        [RefreshProperties(RefreshProperties.Repaint)]
        [ResourceCategoryAttribute("AppearanceCategory"), ResourceDescriptionAttribute("ActiveGradientLowColorDescription"), ResourceDisplayName("DisplayNameActiveGradientLowColor")]
        public Color ActiveGradientLowColor
        {
            get
            {
                return this._gradientTabPage.ActiveGradientLowColor;

            }

            set
            {
                this._gradientTabPage.ActiveGradientLowColor = value;

            }

        }

        /// <summary>
        /// Determines if the ActiveGradientLowColor property has default values or not.
        /// </summary>
        /// <remarks>
        /// This method is used internally to the control and should not be called by your code.
        /// </remarks>
        /// <returns>true or false</returns>
        public bool ShouldSerializeActiveGradientLowColor()
        {
            if (this._gradientTabPage.Parent != null)
            {
                GradientTab parentGradientTab = this._gradientTabPage.Parent as GradientTab;

                if (parentGradientTab != null)
                {
                    if (parentGradientTab.TabActiveGradientLowColor == this._gradientTabPage.ActiveGradientLowColor)
                    {
                        return false;

                    }
                    else
                    {
                        return true;

                    }

                }
                else
                {
                    return true;

                }

            }
            else
            {
                return true;

            }

        }

        /// <summary>
        /// Gets or sets the tab forecolor.
        /// </summary>
        [RefreshProperties(RefreshProperties.Repaint)]
        [ResourceCategoryAttribute("AppearanceCategory"), ResourceDescriptionAttribute("ForeColorDescription"), ResourceDisplayName("DisplayNameForeColor")]
        public Color ForeColor
        {
            get
            {
                return this._gradientTabPage.TabForeColor;

            }

            set
            {
                this._gradientTabPage.TabForeColor = value;

            }

        }

        /// <summary>
        /// Determines if the ForeColor property has default values or not.
        /// </summary>
        /// <remarks>
        /// This method is used internally to the control and should not be called by your code.
        /// </remarks>
        /// <returns>true or false</returns>
        public bool ShouldSerializeForeColor()
        {
            if (this._gradientTabPage.Parent != null)
            {
                GradientTab parentGradientTab = this._gradientTabPage.Parent as GradientTab;

                if (parentGradientTab != null)
                {
                    if (parentGradientTab.TabForeColor == this._gradientTabPage.TabForeColor)
                    {
                        return false;

                    }
                    else
                    {
                        return true;

                    }

                }
                else
                {
                    return true;

                }

            }
            else
            {
                return true;

            }

        }

        /// <summary>
        /// Gets or sets the gradient high (lighter) color for the tab when it is moused over.
        /// </summary>
        /// <value>
        /// <para>
        /// System.Drawing.Color . A Color that represents the gradient high color of the tab when it is moused over.
        /// </para>
        /// <para>
        /// This property is read/write. 
        /// </para>
        /// </value>
        [RefreshProperties(RefreshProperties.Repaint)]
        [ResourceCategoryAttribute("AppearanceCategory"), ResourceDescriptionAttribute("HighlightGradientHighColorDescription"), ResourceDisplayName("DisplayNameHighlightGradientHighColor")]
        public Color HighlightGradientHighColor
        {
            get
            {
                return this._gradientTabPage.HighlightGradientHighColor;

            }

            set
            {
                this._gradientTabPage.HighlightGradientHighColor = value;

            }

        }

        /// <summary>
        /// Determines if the HighlightGradientHighColor property has default values or not.
        /// </summary>
        /// <remarks>
        /// This method is used internally to the control and should not be called by your code.
        /// </remarks>
        /// <returns>true or false</returns>
        public bool ShouldSerializeHighlightGradientHighColor()
        {
            if (this._gradientTabPage.Parent != null)
            {
                GradientTab parentGradientTab = this._gradientTabPage.Parent as GradientTab;

                if (parentGradientTab != null)
                {
                    if (parentGradientTab.TabHighlightGradientHighColor == this._gradientTabPage.HighlightGradientHighColor)
                    {
                        return false;

                    }
                    else
                    {
                        return true;

                    }

                }
                else
                {
                    return true;

                }

            }
            else
            {
                return true;

            }

        }

        /// <summary>
        /// Gets or sets the gradient low (darker) color for the tab when it is moused over.
        /// </summary>
        /// <value>
        /// <para>
        /// System.Drawing.Color . A Color that represents the gradient low color of the tab when it is moused over.
        /// </para>
        /// <para>
        /// This property is read/write. 
        /// </para>
        /// </value>
        [RefreshProperties(RefreshProperties.Repaint)]
        [ResourceCategoryAttribute("AppearanceCategory"), ResourceDescriptionAttribute("HighlightGradientLowColorDescription"), ResourceDisplayName("DisplayNameHighlightGradientLowColor")]
        public Color HighlightGradientLowColor
        {
            get
            {
                return this._gradientTabPage.HighlightGradientLowColor;

            }

            set
            {
                this._gradientTabPage.HighlightGradientLowColor = value;

            }

        }

        /// <summary>
        /// Determines if the HighlightGradientLowColor property has default values or not.
        /// </summary>
        /// <remarks>
        /// This method is used internally to the control and should not be called by your code.
        /// </remarks>
        /// <returns>true or false</returns>
        public bool ShouldSerializeHighlightGradientLowColor()
        {
            if (this._gradientTabPage.Parent != null)
            {
                GradientTab parentGradientTab = this._gradientTabPage.Parent as GradientTab;

                if (parentGradientTab != null)
                {
                    if (parentGradientTab.TabHighlightGradientLowColor == this._gradientTabPage.HighlightGradientLowColor)
                    {
                        return false;

                    }
                    else
                    {
                        return true;

                    }

                }
                else
                {
                    return true;

                }

            }
            else
            {
                return true;

            }

        }

        /// <summary>
        /// The image associated with this control.
        /// </summary>
        /// <value>
        /// 	<para>
        /// System.Drawing.Image . The image associated with this control.
        /// </para>
        /// 	<para>
        /// This property is read/write. 
        /// </para>
        /// </value>
        [ResourceDescriptionAttribute("ImageDescription"), ResourceCategoryAttribute("AppearanceCategory"), ResourceDisplayName("DisplayNameImage"), RefreshProperties(RefreshProperties.Repaint), DefaultValueAttribute(typeof(Image), "(none)")]
        public Image Image
        {
            get
            {
                return this._gradientTabPage.Image;

            }

            set
            {
                this._gradientTabPage.Image = value;

            }

        }

        /// <summary>
        /// The ContentAlignment associated with this controls image.
        /// </summary>
        /// <value>
        /// <para>
        /// System.Drawing.ContentAlignment . The ContentAlignment associated with this controls image.
        /// </para>
        /// <para>
        /// This property is read/write. 
        /// </para>
        /// </value>
        [ResourceCategoryAttribute("AppearanceCategory"), ResourceDescriptionAttribute("ImageAlignmentDescription"), ResourceDisplayName("DisplayNameImageAlign")]
        public ContentAlignment ImageAlign
        {
            get
            {
                return this._gradientTabPage.ImageAlign;

            }

            set
            {
                this._gradientTabPage.ImageAlign = value;

            }

        }

        /// <summary>
        /// Determines if the ImageAlign property has default values or not.
        /// </summary>
        /// <remarks>
        /// This method is used internally to the control and should not be called by your code.
        /// </remarks>
        /// <returns>true or false</returns>
        public bool ShouldSerializeImageAlign()
        {
            if (this._gradientTabPage.Parent != null)
            {
                GradientTab parentGradientTab = this._gradientTabPage.Parent as GradientTab;

                if (parentGradientTab != null)
                {
                    if (parentGradientTab.TabImageAlign == this._gradientTabPage.ImageAlign)
                    {
                        return false;

                    }
                    else
                    {
                        return true;

                    }

                }
                else
                {
                    return true;

                }

            }
            else
            {
                return true;

            }

        }

        /// <summary>
        /// Gets or sets the image list index value of the image displayed on the control. 
        /// </summary>
        [RefreshProperties(RefreshProperties.Repaint), ResourceCategoryAttribute("AppearanceCategory"), ResourceDisplayName("DisplayNameImageIndex"), TypeConverter(typeof(ImageIndexConverter)), Editor("System.Windows.Forms.Design.ImageIndexEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(UITypeEditor)), Localizable(true), ResourceDescriptionAttribute("ImageIndexDescription"), DefaultValue(-1)]
        public int ImageIndex
        {
            get
            {
                return this._gradientTabPage.ImageIndex;

            }

            set
            {
                this._gradientTabPage.ImageIndex = value;

            }

        }

        /// <summary>
        /// Gets or sets the image list key value of the image displayed on the control. 
        /// </summary>
        [ResourceCategoryAttribute("AppearanceCategory"), ResourceDisplayName("DisplayNameImageKey"), TypeConverter(typeof(ImageKeyConverter)), Editor("System.Windows.Forms.Design.ImageIndexEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(UITypeEditor)), Localizable(true), DefaultValue(""), RefreshProperties(RefreshProperties.Repaint), ResourceDescriptionAttribute("ImageIndexDescription")]
        public string ImageKey
        {
            get
            {
                return this._gradientTabPage.ImageKey;

            }

            set
            {
                this._gradientTabPage.ImageKey = value;

            }

        }

        /// <summary>
        /// Gets or sets the ImageList that contains the Image displayed on the tab of the control. 
        /// </summary>
        [ResourceCategoryAttribute("AppearanceCategory"), ResourceDescriptionAttribute("ImageListDescription"), ResourceDisplayName("DisplayNameImageList"), RefreshProperties(RefreshProperties.Repaint), DefaultValueAttribute(typeof(ImageList), "(none)")]
        public ImageList ImageList
        {
            get
            {
                return this._gradientTabPage.ImageList;

            }

            set
            {
                this._gradientTabPage.ImageList = value;

            }

        }

        /// <summary>
        /// Gets or sets the gradient high (lighter) color for the control.
        /// </summary>
        /// <value>
        /// 	<para>
        /// System.Drawing.Color . A Color that represents the gradient high color of the control.
        /// </para>
        /// 	<para>
        /// This property is read/write. 
        /// </para>
        /// </value>
        [RefreshProperties(RefreshProperties.Repaint)]
        [ResourceCategoryAttribute("AppearanceCategory"), ResourceDescriptionAttribute("GradientHighColorDescription"), ResourceDisplayName("DisplayNameGradientHighColor")]
        public Color GradientHighColor
        {
            get
            {
                return this._gradientTabPage.GradientHighColor;

            }

            set
            {
                this._gradientTabPage.GradientHighColor = value;

            }

        }

        /// <summary>
        /// Determines if the GradientHighColor property has default values or not.
        /// </summary>
        /// <remarks>
        /// This method is used internally to the control and should not be called by your code.
        /// </remarks>
        /// <returns>true or false</returns>
        public bool ShouldSerializeGradientHighColor()
        {
            if (this._gradientTabPage.Parent != null)
            {
                GradientTab parentGradientTab = this._gradientTabPage.Parent as GradientTab;

                if (parentGradientTab != null)
                {
                    if (parentGradientTab.TabGradientHighColor == this._gradientTabPage.GradientHighColor)
                    {
                        return false;

                    }
                    else
                    {
                        return true;

                    }

                }
                else
                {
                    return true;

                }

            }
            else
            {
                return true;

            }

        }

        /// <summary>
        /// Gets or sets the gradient low (darker) color for the control.
        /// </summary>
        /// <value>
        /// 	<para>
        /// System.Drawing.Color . A Color that represents the gradient low color of the control.
        /// </para>
        /// 	<para>
        /// This property is read/write. 
        /// </para>
        /// </value>
        [RefreshProperties(RefreshProperties.Repaint)]
        [ResourceCategoryAttribute("AppearanceCategory"), ResourceDescriptionAttribute("GradientLowColorDescription"), ResourceDisplayName("DisplayNameGradientLowColor")]
        public Color GradientLowColor
        {
            get
            {
                return this._gradientTabPage.GradientLowColor;

            }

            set
            {
                this._gradientTabPage.GradientLowColor = value;

            }

        }

        /// <summary>
        /// Determines if the GradientLowColor property has default values or not.
        /// </summary>
        /// <remarks>
        /// This method is used internally to the control and should not be called by your code.
        /// </remarks>
        /// <returns>true or false</returns>
        public bool ShouldSerializeGradientLowColor()
        {
            if (this._gradientTabPage.Parent != null)
            {
                GradientTab parentGradientTab = this._gradientTabPage.Parent as GradientTab;

                if (parentGradientTab != null)
                {
                    if (parentGradientTab.TabGradientLowColor == this._gradientTabPage.GradientLowColor)
                    {
                        return false;

                    }
                    else
                    {
                        return true;

                    }

                }
                else
                {
                    return true;

                }

            }
            else
            {
                return true;

            }

        }

        /// <summary>
        /// Gets or sets the font associated with the tab.
        /// </summary>
        [RefreshProperties(RefreshProperties.Repaint)]
        [ResourceCategoryAttribute("AppearanceCategory"), ResourceDescriptionAttribute("TabFontDescription"), ResourceDisplayName("DisplayNameTabFont")]
        public Font TabFont
        {
            get
            {

                return this._gradientTabPage.TabFont;

            }

            set
            {
                this._gradientTabPage.TabFont = value;

            }

        }

        /// <summary>
        /// Determines if the TabFont property has default values or not.
        /// </summary>
        /// <remarks>
        /// This method is used internally to the control and should not be called by your code.
        /// </remarks>
        /// <returns>true or false</returns>
        public bool ShouldSerializeTabFont()
        {
            if (this._gradientTabPage.Parent != null)
            {
                GradientTab parentGradientTab = this._gradientTabPage.Parent as GradientTab;

                if (parentGradientTab != null)
                {
                    if ((parentGradientTab.TabFont.Name != this.TabFont.Name) || (this.TabFont.Size != 8.25f) || (this.TabFont.Bold != false))
                    {
                        return true;

                    }
                    else
                    {
                        return false;

                    }

                }
                else
                {
                    return true;

                }

            }
            else
            {
                return true;

            }

        }

        /// <summary>
        /// Resets the tab font to default values.
        /// </summary>
        public void ResetTabFont()
        {
            if (this._gradientTabPage.Parent != null)
            {
                GradientTab parentGradientTab = this._gradientTabPage.Parent as GradientTab;

                if (parentGradientTab != null)
                {
                    if (parentGradientTab.TabFont != null)
                    {
                        this.TabFont = new Font(parentGradientTab.TabFont.Name, 8.25f, FontStyle.Bold);

                    }
                    else if (parentGradientTab.Parent.Font != null)
                    {
                        this.TabFont = new Font(parentGradientTab.Parent.Font.Name, 8.25f, FontStyle.Bold);

                    }
                    else
                    {
                        this.TabFont = new Font(System.Windows.Forms.Control.DefaultFont.Name, 8.25f, FontStyle.Bold);

                    }

                }
                else
                {
                    this.TabFont = new Font(System.Windows.Forms.Control.DefaultFont.Name, 8.25f, FontStyle.Bold);

                }

            }
            else
            {
                this.TabFont = new Font(System.Windows.Forms.Control.DefaultFont.Name, 8.25f, FontStyle.Bold);

            }

        }

        /// <summary>
        /// Gets or sets the text associated with this control's tab. 
        /// </summary>
        /// <value>
        /// The text associated with this control's button. 
        /// </value>
        [RefreshProperties(RefreshProperties.Repaint)]
        [ResourceCategoryAttribute("AppearanceCategory"), ResourceDescriptionAttribute("TextDescription"), ResourceDisplayName("DisplayNameText"), DefaultValueAttribute("")]
        public string Text
        {
            get
            {
                return this._gradientTabPage.Text;

            }

            set
            {
                this._gradientTabPage.Text = value;

            }

        }

        /// <summary>
        /// The ContentAlignment associated with this controls text.
        /// </summary>
        /// <value>
        /// <para>
        /// System.Drawing.ContentAlignment . The ContentAlignment associated with this controls text.
        /// </para>
        /// <para>
        /// This property is read/write. 
        /// </para>
        /// </value>
        [ResourceCategoryAttribute("AppearanceCategory"), ResourceDescriptionAttribute("TextAlignmentDescription"), ResourceDisplayName("DisplayNameTextAlign")]
        public ContentAlignment TextAlign
        {
            get
            {
                return this._gradientTabPage.TextAlign;

            }

            set
            {
                this._gradientTabPage.TextAlign = value;

            }

        }

        /// <summary>
        /// Determines if the TextAlign property has default values or not.
        /// </summary>
        /// <remarks>
        /// This method is used internally to the control and should not be called by your code.
        /// </remarks>
        /// <returns>true or false</returns>
        public bool ShouldSerializeTextAlign()
        {
            if (this._gradientTabPage.Parent != null)
            {
                GradientTab parentGradientTab = this._gradientTabPage.Parent as GradientTab;

                if (parentGradientTab != null)
                {
                    if (parentGradientTab.TabTextAlign == this._gradientTabPage.TextAlign)
                    {
                        return false;

                    }
                    else
                    {
                        return true;

                    }

                }
                else
                {
                    return true;

                }

            }
            else
            {
                return true;

            }

        }

        /// <summary>
        /// The tooltip text to display.
        /// </summary>
        [ResourceDescriptionAttribute("ToolTipDescription"), ResourceCategoryAttribute("AppearanceCategory"), ResourceDisplayName("DisplayNameToolTipText")]
        public string ToolTipText
        {
            get
            {
                return this._gradientTabPage.ToolTipText;

            }

            set
            {
                this._gradientTabPage.ToolTipText = value;

            }

        }

        /// <summary>
        /// Gets a value indicating whether drop-down editors should be resizable by the user.
        /// </summary>
        [Browsable(false)]
        public override bool IsDropDownResizable
        {
            get
            {
                return false;

            }

        }

        /// <summary>
        /// Initializes a new instance of the NavigationPaneButtonProperty class.
        /// </summary>
        /// <param name="gradientTabPage">The GradientTabPage control to add the property values to.</param>
        public GradientTabPageTabProperty(GradientTabPage gradientTabPage)
        {
            this._gradientTabPage = gradientTabPage;

        }

        /// <summary>
        /// Initializes a new instance of the GradientTabPageTabProperty class.
        /// </summary>
        /// <param name="gradientTabPage"></param>        
        /// <param name="gradientHighColor">The gradient high color of the button.</param>
        /// <param name="gradientLowColor">The gradient low color of the button.</param>        
        /// <param name="highlightGradientHighColor">The gradient high (lighter) color for the button when it is moused over.</param>
        /// <param name="highlightGradientLowColor">The gradient low (darker) color for the button when it is moused over.</param>
        /// <param name="activeGradientHighColor">The gradient high (lighter) color for the button when it is active.</param>
        /// <param name="activeGradientLowColor">The gradient low (darker) color for the button when it is active.</param>
        /// <param name="foreColor">The button forecolor.</param>
        public GradientTabPageTabProperty(GradientTabPage gradientTabPage,
            Color gradientHighColor,
            Color gradientLowColor,
            Color highlightGradientHighColor,
            Color highlightGradientLowColor,
            Color activeGradientHighColor,
            Color activeGradientLowColor,
            Color foreColor
            )
        {
            this._gradientTabPage = gradientTabPage;

            this.GradientHighColor = gradientHighColor;
            this.GradientLowColor = gradientLowColor;

            this.HighlightGradientHighColor = highlightGradientHighColor;
            this.HighlightGradientLowColor = highlightGradientLowColor;
            this.ActiveGradientHighColor = activeGradientHighColor;
            this.ActiveGradientLowColor = activeGradientLowColor;
            this.ForeColor = foreColor;
            

        }

    }

}
